package com.quectel.core.module.entranceguard.entity.mongo;

import com.quectel.constant.BackupConfigConstants;
import com.quectel.core.constants.MongoCollectionConstants;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.Data;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;

/**
 * 人员访问记录表
 *
 * @author caolu
 * @email louis.cao@quectel.com
 * @date 2021-11-17 18:31:06
 */
@Data
@Document(MongoCollectionConstants.PERSON_ACCESS_RECORD)
@CompoundIndex(name = "idx_device_id", def = "{'deviceId': 1}", background = true)
@CompoundIndex(name = "idx_tenant_village", def = "{'tenantId': 1,'villageId': 1}", background = true)
@CompoundIndex(name = "idx_person", def = "{'personType': 1,'personId': 1}", background = true)
public class MongoPersonAccessRecordModel implements MongoBaseModel {

    /**
     * id
     */
    @MongoId
    private Long id;

    /**
     * 租户id
     */
    private Long tenantId;

    /**
     * 小区id
     */
    private Long villageId;


    /**
     * 楼栋id
     */
    private Long buildingId;
    /**
     * 种类id
     */
    private Long deviceCategoryId;

    /**
     * 类型
     */
    private Long deviceTypeId;

    /**
     * 门禁设备id
     */
    private Long deviceId;

    /**
     * 人员类型 1住户2访客
     */
    private Byte personType;

    /**
     * 人员id 住户或访客
     */
    private Long personId;

    /**
     * 人员名称
     */
    private String personName;

    /**
     * 手机号
     */
    private String personMobile;

    /**
     * 是否重点人员 1是0否 默认是0
     */
    @Indexed(name = "idx_focus", background = true)
    private Byte focus = 0;

    /**
     * 门禁设备名称
     */
    private String deviceName;

    /**
     * 访问方式 0其他 1远程 2蓝牙 3二维码 4人脸  5临时密码 6刷卡
     */
    private Byte accessMode;

    /**
     * 进出方式 0未知 1进 2出
     */
    private Byte outOrIn;

    /**
     * 抓拍照片
     */
    private String snapImages;

    /**
     * 抓拍视频
     */
    private String snapVideoes;

    /**
     * 事件发生的时间
     */
    private Date eventTime;

    /**
     * 访问时间
     */
    @Indexed(name = "idx_access_time", background = true, expireAfterSeconds = BackupConfigConstants.MONGO_LOG_DATA_DEFAULT_RETAIN_SECONDS)
    private Date accessTime;

    /**
     * 纬度
     */
    private Double latitude;

    /**
     * 经度
     */
    private Double longitude;


}
